package br.edu.ufcg.ga.output;

import br.edu.ufcg.ga.CaixeiroViajante;
import br.edu.ufcg.ga.stopcondition.StopCondition;

public class MainRunOutputGenerator implements OutputGenerator {

	@Override
	public void generateOutput(double bestFitnessValue, CaixeiroViajante cv) throws Exception {
		long seed = cv.getRandom().getSeed();
		generateGeneralOutput(bestFitnessValue, cv, seed);
	}
	
	protected void generateGeneralOutput(double bestFitnessValue, CaixeiroViajante cv, long seed) throws Exception {
		StopCondition sc = cv.getStopCondition();
		String content = sc.getNumGenerations() + " " + sc.getCMaxRepetitionOfBestFitness() + " " + bestFitnessValue
		+ " " + (cv.getEndTime() - cv.getInitTime()) + " " + seed;
		writeGeneralOutput(content, seed);
	}
	
	protected void writeGeneralOutput(String content, long seed) throws Exception {
		System.out.println(content);
	}

}
